<template>
  <div class="container">
    <div class="app-container">
      <el-input v-model="pageParams.enterpriseName" size="mini" placeholder="请输入企业名称" style="width: 200px; margin-right: 10px;" />
      <el-date-picker
        v-model="dateRange"
        size="mini"
        type="daterange"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button size="mini" type="primary" style="border-radius: 4px;margin-left: 20px;" @click="search">查询</el-button>
      <el-col style="margin-top: 20px;">
        <el-button type="primary" size="mini" style="border-radius: 4px;margin-left: 20px;">添加账单</el-button>
      </el-col>
      <el-table :data="list" style="width: 100%; margin-top: 20px;">
        <el-table-column align="center" type="index" label="序号" />
        <el-table-column align="center" prop="billNumber" label="账单编号" />
        <el-table-column align="center" prop="enterpriseName" label="企业名称" />
        <el-table-column align="center" prop="buildingName" label="租赁楼宇" />
        <el-table-column align="center" prop="propertyFeePrice" label="物业费(元/m²)" />
        <el-table-column align="center" prop="paymentAmount" label="账单金额(元)" />
        <el-table-column align="center" prop="createTime" label="缴费时间" />
        <el-table-column align="center" label="操作">
          <template>
            <el-button size="mini">查看</el-button>
            <el-button size="mini" type="danger">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="pageParams.page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageParams.pagesize"
        layout="total, sizes, prev, pager,next,jumper "
        :total="total"
        @current-change="changePage"
      />
    </div>
  </div>
</template>

<script>
import { getPropertyAPI } from '@/api'

export default {
  name: 'PropertyManagement',
  data() {
    return {
      list: [],
      pageParams: {
        enterpriseName: '',
        page: 1,
        pagesize: 10,
        dateRange: []
      },
      dateRange: [],
      total: 0
    }
  },
  created() {
    this.pageParams.dateRange = this.dateRange
    this.getProperty()
  },
  methods: {
    search() {
      this.pageParams.page = 1
      this.getProperty()
    },
    async getProperty() {
      const { rows, total } = await getPropertyAPI(this.pageParams)
      this.list = rows
      this.total = total
    },
    changePage(newPage) {
      this.pageParams.page = newPage
      this.getProperty()
    }
  }
}
</script>

